// src/stores/productStore.ts
import { defineStore } from 'pinia'

export interface Product {
  id: number
  name: string
  price: number
}

interface ProductState {
  productList: Product[]
}

export const useProductStore = defineStore('product', {
  state: (): ProductState => ({
    productList: []
  }),
  actions: {
    async fetchProducts() {
      // 模拟异步请求
      const mockData: Product[] = [
        { id: 1, name: '苹果', price: 3 },
        { id: 2, name: '香蕉', price: 2 }
      ]
      this.productList = mockData
    }
  }
})
